<template>
	<view id="charging">
		<headerTar title="充电中" />
		<view class="top">
			<view class="container">
				<view class="header"></view>
				<view class="battery">
				</view>
				<view class="battery-copy">
					<view class="g-wave"></view>
					<view class="g-wave"></view>
					<view class="g-wave"></view>
				</view>
			</view>
		</view>
		<view class="center">
			<view class="c_title"><img class="img" src="@/static/map/location.png" alt="">
				{{data.deviceName}}{{data.portNo}}端口
			</view>
			<view class="c_floot">
				<view class="c_box">
					<view class="c_box_t1">
						<span class="c_box_yu">预收</span> 10 <span class="c_box_yuan">元</span>
					</view>
					<view class="c_box_t2">
						消费金额
					</view>
				</view>
				<view class="c_box">
					<view class="c_box_t1">
						{{data.startTime}}
					</view>
					<view class="c_box_t2">
						开始时间
					</view>
				</view>
				<view class="c_box">
					<view class="c_box_t1">
						{{data.preChargeTime}}分钟
					</view>
					<view class="c_box_t2">
						按时间充电
					</view>
				</view>
			</view>
		</view>

		<view class="bottom">
			<view class="b_left">
				领充电金
			</view>
			<view class="b_right" @click="endCharge">
				结束充电
			</view>
		</view>
	</view>
</template>

<script>
	import headerTar from '@/components/headerTar/header'
	import {
		getChargingOrderAPi,
		stopChargeApi
	} from '@/api/pay.js'
	export default {
		components: {
			headerTar
		},
		data() {
			return {
				data: ''
			}
		},
		onLoad() {
			this.getgetChargingOrder()
		},
		methods: {
			getgetChargingOrder() {
				getChargingOrderAPi().then(v => {
					this.data = v.data
				})
			},
			endCharge() {
				console.log(this.data.orderNo, '=========this.data.orderNo');
				stopChargeApi({
					orderNo: this.data.orderNo
				}).then(v => {
					uni.navigateTo({
						url: '/pages/chargingOrder/chargingOrder'
					});
				})
			}
		},
	}
</script>

<style lang="scss" scoped>
	#charging {
		background-color: #f7f7f7;
		height: 100vh;

		.center {
			margin: 30rpx;
			border-radius: 20rpx;
			background-color: #fff;

			.c_title {
				padding: 20rpx;
				font-size: 28rpx;
				font-weight: bold;
				vertical-align: top;

				.img {
					width: 40rpx;
					height: 40rpx;
					vertical-align: middle;
					margin-top: -6rpx;
					margin-right: 8rpx;
				}
			}

			.c_floot {
				padding-left: 20rpx;
				height: 160rpx;
				display: flex;
				align-items: center;
				border-radius: 15rpx;
				background: linear-gradient(to bottom, #effff5, #ffffff);

				.c_box {
					font-size: 28rpx;
					flex: 1;

					.c_box_t1 {
						margin-bottom: 10rpx;
						font-weight: bold;
						letter-spacing: 2rpx;
						font-size: 26rpx;

						.c_box_yu {
							font-size: 22rpx;
							color: #f3a719;
						}

						.c_box_yuan {
							font-size: 22rpx;
						}
					}

					.c_box_t2 {
						font-size: 24rpx;
						color: #7c8782;
					}
				}
			}
		}

		.bottom {
			position: absolute;
			left: 0;
			bottom: 0;
			height: 140rpx;
			line-height: 140rpx;
			width: 100%;
			background-color: #fff;
			border-top-left-radius: 20rpx;
			border-top-right-radius: 20rpx;

			.b_left {
				display: inline-block;
				width: 160rpx;
				height: 60rpx;
				line-height: 60rpx;
				border-radius: 30rpx;
				text-align: center;
				margin-left: 30rpx;
				font-size: 28rpx;
				color: #fff;
				/* background: linear-gradient(to top, #fd290e, ##f46750); */
				background-color: #fc4526;
			}

			.b_right {
				display: inline-block;
				width: 500rpx;
				height: 70rpx;
				line-height: 70rpx;
				border-radius: 35rpx;
				text-align: center;
				margin-left: 30rpx;
				font-size: 28rpx;
				color: #fff;
				background: linear-gradient(to right, #48ce79, #2fbe62);
			}
		}


		.container {
			position: relative;
			width: 140px;
			margin: auto;
		}

		.header {
			position: absolute;
			width: 26px;
			height: 10px;
			left: 50%;
			top: 0;
			transform: translate(-50%, -10px);
			border-radius: 5px 5px 0 0;
			background: rgba(255, 255, 255, .88);
		}

		.battery-copy {
			position: absolute;
			top: 0;
			left: 0;
			height: 220px;
			width: 140px;
			border-radius: 15px 15px 5px 5px;
			overflow: hidden;
		}

		.battery {
			position: relative;
			height: 220px;
			box-sizing: border-box;
			border-radius: 15px 15px 5px 5px;
			box-shadow: 0 0 5px 2px rgba(255, 255, 255, 0.22);
			background: #fff;
			z-index: 1;

			&::after {
				content: "";
				position: absolute;
				left: 0;
				right: 0;
				bottom: 0;
				top: 80%;
				background: linear-gradient(to bottom, #7abcff 0%, #00BCD4 44%, #2196F3 100%);
				border-radius: 0px 0px 5px 5px;
				box-shadow: 0 14px 28px rgba(33, 150, 243, 0), 0 10px 10px rgba(9, 188, 215, 0.08);
				animation: charging 10s linear infinite;
				filter: hue-rotate(90deg);
			}
		}

		.g-wave {
			position: absolute;
			width: 300px;
			height: 300px;
			background: rgba(255, 255, 255, .8);
			border-radius: 45% 47% 44% 42%;
			bottom: 25px;
			left: 50%;
			transform: translate(-50%, 0);
			z-index: 1;
			animation: move 10s linear infinite;
		}

		.g-wave:nth-child(2) {
			border-radius: 38% 46% 43% 47%;
			transform: translate(-50%, 0) rotate(-135deg);
		}

		.g-wave:nth-child(3) {
			border-radius: 42% 46% 37% 40%;
			transform: translate(-50%, 0) rotate(135deg);
		}

		@keyframes charging {
			50% {
				box-shadow: 0 14px 28px rgba(0, 150, 136, 0.83), 0px 4px 10px rgba(9, 188, 215, 0.4);
			}

			95% {
				top: 5%;
				filter: hue-rotate(0deg);
				border-radius: 0 0 5px 5px;
				box-shadow: 0 14px 28px rgba(4, 188, 213, .2), 0 10px 10px rgba(9, 188, 215, 0.08);
			}

			100% {
				top: 0%;
				filter: hue-rotate(0deg);
				border-radius: 15px 15px 5px 5px;
				box-shadow: 0 14px 28px rgba(4, 188, 213, 0), 0 10px 10px rgba(9, 188, 215, 0.4);
			}
		}

		@keyframes move {
			100% {
				transform: translate(-50%, -160px) rotate(720deg);
			}
		}
	}
</style>